#!/usr/bin/node

const log = console.log,
      http = require('http'),
      fs= require('fs');

function loaditems(){
  log('loaditems');
  try{
    let items = fs.readFileSync('./12-items-txt').toString('utf8');
    items = JSON.parse(items);
    return items;

  }catch(e){
    console.error(e.message);
    return []
  }

  function saveItems(){
    log('saveitems');
    return [];
  }

  http.createServer((req,res)=>{
    printRequest(req);
    if(req.url === '/' && req.method === 'GET'){
      showHomePage(res);
    }
  }).listen(3000)
}
